<template>
  <div class="mediation-effect">
    <div class="mediation-effect-item" v-for="(item, index) in mediationItems" :key="index" @click="showDialog(index)">
      <div class="image-container">
        <img :src="item.mainImage" :alt="item.title">
      </div>
      <div class="title">{{ item.title }}</div>
    </div>

    <Dialog v-if="info.show" :info="info">
      <div class="dialog-content">
        <div class="description">{{ currentItem.description }}</div>
        <div class="image-gallery">
          <div class="gallery-item" v-for="(image, idx) in currentItem.images" :key="idx">
            <img :src="image" :alt="currentItem.title + '图片' + (idx + 1)">
          </div>
        </div>
      </div>
    </Dialog>
  </div>
</template>

<script>
import Dialog from "@/components/dialog/Dialog";

export default {
  name: 'MediationEffect',
  components: { Dialog },
  data() {
    return {
      currentIndex: 0,
      info: {
        title: '',
        width: '90%',
        show: false,
        subTitle: ''
      },
      mediationItems: [
        {
          title: '妈妈唠嗑队',
          description: '妈妈唠嗑队排查化解矛盾纠纷',
          mainImage: 'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/mama/WechatIMG161.jpeg',
          images: [
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/mama/WechatIMG161.jpeg',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/mama/WechatIMG162.png',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/mama/WechatIMG178.jpeg'
          ]
        },
        {
          title: '小板凳议事会',
          description: '小板凳议事会排查化解矛盾纠纷',
          mainImage: 'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/xiaobandeng/WechatIMG175.jpeg',
          images: [
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/xiaobandeng/WechatIMG158.png',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/xiaobandeng/WechatIMG157.jpeg',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/xiaobandeng/WechatIMG200.jpeg'
          ]
        },
        {
          title: '警网融合走访',
          description: '网格警长联合网格长走访排查化解矛盾纠纷',
          mainImage: 'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/ruhu/WechatIMG164.jpeg',
          images: [
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/ruhu/WechatIMG169.jpeg',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/ruhu/WechatIMG170.jpeg',
            'https://police-station-1306862033.cos.ap-chengdu.myqcloud.com/jinquan/jianying/tiaojie/ruhu/WechatIMG171.jpeg'
          ]
        }
      ]
    }
  },
  computed: {
    currentItem() {
      return this.mediationItems[this.currentIndex]
    }
  },
  methods: {
    showDialog(index) {
      this.currentIndex = index
      this.info.title = this.currentItem.title
      this.info.show = true
    }
  }
}
</script>

<style scoped lang="scss">
.mediation-effect{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;

  .mediation-effect-item{
    width: calc(100%/3 - 10px);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    .image-container {
      width: 100%;
      height: calc(100% - 30px);
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      border: 2px solid rgba(50, 180, 255, 0.3);
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: rgba(0, 0, 0, 0.1);
      padding: 0;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;

        &:hover {
          transform: scale(1.05);
        }
      }
    }

    .title {
      margin-top: 10px;
      color: #32B4FF;
      font-size: 16px;
      font-weight: bold;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
  }
}

:deep(.dialog-content) {
  .description {
    font-size: 28px;
    font-weight: bold;
    line-height: 1.6;
    color: #fff;
    margin-bottom: 20px;
    padding: 15px;
    background-color: rgba(6, 33, 59, 0.8);
    border-radius: 8px;
    border-left: 4px solid #32B4FF;
    text-align: center;
  }

  .image-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 10px;

    .gallery-item {
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      transition: transform 0.3s ease;
      border: 2px solid rgba(50, 180, 255, 0.3);

      &:hover {
        transform: translateY(-5px);
      }

      img {
        width: 100%;
        height: 300px;
        object-fit: cover;
      }
    }
  }
}
</style>
